FROM yjs-code:latest

ARG X_GID
ARG X_UID

COPY  ./composer/ /home/clonetrooper/.composer/

RUN set -eux; \
    if [ -z "`getent group ${X_UID}`" ]; then \
        addgroup --system --gid ${X_GID} clonetrooper; \
    fi; \
    adduser --system --disabled-password -S --uid ${X_UID} -G clonetrooper clonetrooper \
    && apk add -U tzdata \
    && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
    && apk del tzdata \
    && rm -rf /var/cache/apk/* \
    && rm -rf /root/.cache \
    && rm -rf /tmp/* \
    && { \
        echo '[www]'; \
        echo; \
        echo "user = ${X_UID}"; \
        echo "group = ${X_GID}"; \
    } | tee /usr/local/etc/php-fpm.d/zzz.conf \
   && mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" && \
    mkdir /run/php && \
    chown -R clonetrooper:clonetrooper /run &&\
    mkdir -p -m 0700 /home/clonetrooper/.ssh && \
    chown -R clonetrooper:clonetrooper /home/clonetrooper && \
    mkdir -p /data/www/yjs && \
    chown -R clonetrooper:clonetrooper /data/www/yjs  

WORKDIR /data/www/yjs

USER clonetrooper
RUN  ssh-keyscan dx.wangcaigu.cn >> /home/clonetrooper/.ssh/known_hosts  && \
     git pull origin
#     composer global require "fxp/composer-asset-plugin:~1.4.5" -vvv && \
#     composer config -g repo.packagist composer https://http://repo.lianhejinxin.com/  && \
#     composer install --ignore-platform-reqs --no-dev --prefer-dist -o -vvv

#COPY --chown=clonetrooper:clonetrooper ./env/.env /data/www/yjs/.env 
COPY --chown=clonetrooper:clonetrooper ./conf/ /data/www/yjs/common/config/
